<template>
    <div>
      <el-table
        :data="profitList"
        border
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header"
      >
        <el-table-column
          fixed
          prop="id"
          label="编号"
        >
        </el-table-column>
        <el-table-column
          prop="priceAmount"
          label="今日盈利金额"
        >
        </el-table-column>
        <el-table-column
          prop="userAmount"
          label="今日新增用户数"
        >
        </el-table-column>
        <el-table-column
          prop="day"
          label="日期"
        >
        </el-table-column>
      </el-table>

      <div class="pagination">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="total"
          :current-page="currentPage"
          :page-size="size"
          @current-change="getData">
        </el-pagination>
      </div>
    </div>
</template>

<script>
  import {profitList} from '../../network/profitList'

  export default {
    name: 'ProfitManage',
    methods:{

      getData (currentPage) {
        console.log('表单')
        profitList(currentPage)
          .then((res) => {
            console.log(res)
            if (res.data.code === 80200) {
              console.log(res)
              this.tableData = res.data.data
              this.tableData.forEach(item => {
                item.status = Boolean(item.status)
              })

              this.total = res.data.data.total
              this.size = res.data.data.size
              this.current = res.data.data.current
            } else {
              this.$message.error('数据获取失败，' + res.data.data.msg)
            }
          })
          .catch(() => {
            this.$message.error('数据获取失败，请在保证网络畅通的情况下检查请求的地址或参数是否正确')
          })
      },
    },
    data(){
      return{
        profitList:[],
        tableData:[],
        total:0,
        pages:1,
        size:10,
        currentPage:1,
      }
    },
    created () {
      var _this = this;
      _this.$http.post('http://8.135.35.123:9000/hotelsystem/profit/list').then(function (res) {
        if(res.data.code==80200){
          _this.profitList = res.data.data;
          _this.total = res.data.data.total;
          _this.pages = res.data.data.pages;
          _this.size = res.data.data.size;
          _this.currentPage = res.data.data.current;
        }
      })
    }
  }
</script>

<style scoped>

</style>
